package com.forenow.demo.Book;

import java.util.Scanner;

public class MainBook {
    public void huiz(int[] a){
        int i;
        Book bo=new Book();
        int[] arr1= new int[3];
        for (i=0;i<arr1.length;i++){
            Double sum=0.0;
            sum+=bo.getPrice();
        }
    }
    public void ddze(Book[] a){
        Book[] arr=new Book[3];
        System.out.print("订单总额：");

    }
    public static void main(String[] args) {
        int amount1;
        int id;
        Book b1=new Book(1,"Java",33.4,50);
        Book b2=new Book(2,"Jsp",55.45,150);
        Book b3=new Book(3,"sm",77.45,250);
        System.out.println(b1.getBookid()+"\t"+b1.getBookname()+"\t"+b1.getAmount());
        System.out.println(b2.getBookid()+"\t"+b2.getBookname()+"\t\t"+b2.getAmount());
        System.out.println(b3.getBookid()+"\t"+b3.getBookname()+"\t\t"+b3.getAmount());
        while (true){
            System.out.println("请输入图书编号：");
            Scanner sc=new Scanner(System.in);
            Double d=sc.nextDouble();
            Book[] arr=new Book[3];
            arr[0]=b1;
            arr[1]=b2;
            arr[2]=b3;
            for (int i=0;i<arr.length;i++){
                int a=arr[i].getBookid();
                if (a==d){
                    System.out.println("请输入购买数量：");
                    amount1=sc.nextInt();
                    int oldmount=arr[i].getAmount();
                    arr[i].setAmount(oldmount-amount1);
                    int newmount=arr[i].getAmount();
                    System.out.println("请继续购买图书");
                }
            }
            if (d.equals("0001")){
                break;
            }
        }



            }
}
